var href = window.location.href;

if (isMobilePhone()) {
    $(".fix-header .navbar-collapse .navbar-nav > li:not(:first) > a").attr("href", "javascript:;");
    $(".fix-header .navbar-collapse .navbar-nav > li:not(:first)").removeClass("dropdown");
    $(".fix-header .navbar-collapse .navbar-nav > li:not(:first) > a").removeAttr("target");
    $(".fix-header .navbar-collapse .navbar-nav > li:not(:first) > a").on("click", function () {
        $(this).parent().siblings().removeClass("open");
        $(this).parent().addClass("open");
    })
}
$(".dropdown .dropdown-toggle").each(function () {
    if (href.search($(this).attr('href')) != -1 && $(this).attr('href') != '') {
        $(this).addClass("selected");
        $(this).addClass("test");
    }
    if (href.search("zxnszwxq") != -1 && $(this).attr('href') != '') {
        $("#nav_2").addClass("selected");
        $("#nav_2").addClass("test");
    }
    if (href.search("newslist") != -1 && $(this).attr('href') != '') {
        $("#nav_6").addClass("selected");
        $("#nav_6").addClass("test");
    }
    if (href.search("caselist") != -1 && $(this).attr('href') != '') {
        $("#nav_4").addClass("selected");
        $("#nav_4").addClass("test");
    }
});
function isMobilePhone() {
    if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {
        return true;
    } else {
        return false;
    }
}

window.isMobilePhone = isMobilePhone;
/**
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 */


$(window).scroll(function () {
    handleStart();
    var flexsliderH = $(".flexslider").height();
    var secondH = $(".second").height();
    var thirdH = $(".third").height();
    var fourthH = $(".fourth").height();
    // if ($(window).scrollTop() > flexsliderH - 170) {
    //     $(".column1").css('opacity',0).addClass("fadeInLeft");
    //     $(".column2").css('opacity',0).addClass("fadeIn");
    //     $(".column3").css('opacity',0).addClass("fadeInRight");
    // }
    // if ($(window).scrollTop() > flexsliderH + secondH - 500) {
    //     $(".dxyh_gxyh").attr("data-animation", "fadeInLeft");
    //     $(".dxyh_qtyh").attr("data-animation", "fadeInRight");
    // }
    // if ($(window).scrollTop() > flexsliderH + secondH + thirdH - 500) {
    //     $(".nav-one").attr("data-animation", "fadeInLeft");
    //     $(".nav-two").attr("data-animation", "fadeInRight");
    //     $("#featured,#core").attr("data-animation", "fadeInLeft");
    //     $("#core").attr("data-animation", "fadeInRight");
    // }
});

/**
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
var clientWidth = document.body.clientWidth;
var flag = true;
if (clientWidth <= 767) {
    flag = false;
}
$(function () {
    $(".xScroll").xScroll();
    $(".flexslider").flexslider({
        directionNav: flag,
        animation: "slide",
        slideshow: flag,
        slideshowSpeed: 5000,
        pauseOnHover: true,
        keyboardNav: true,
        touch: true,
        useCSS: true,
        video: true,
        pauseOnAction: true,
    });
    $("div[id^='column']").hover(
        function () {
            $(this).find("img").css({ transform: "scale(1.2)" });
        },
        function () {
            $(this).find("img").css({ transform: "scale(1)" });
        }
    );
    if (isMobilePhone()) {
        var swiper1 = new Swiper(".xn-swiper-animated1", {
            slidesPerView: 1,
            slidesPerColumn: 5,
            spaceBetween: 20,
            pagination: {
                el: ".xn-swiper-animated1 .swiper-pagination",
                clickable: true,
            },
            navigation: {
                nextEl: ".xn-swiper-animated1 .swiper-button-next",
                prevEl: ".xn-swiper-animated1 .swiper-button-prev",
            },
        });
    } else {
        var swiper1 = new Swiper(".xn-swiper-animated1", {
            slidesPerView: 1,
            slidesPerColumn: 3,
            spaceBetween: 20,
            pagination: {
                el: ".xn-swiper-animated1 .swiper-pagination",
                clickable: true,
            },
            navigation: {
                nextEl: ".xn-swiper-animated1 .swiper-button-next",
                prevEl: ".xn-swiper-animated1 .swiper-button-prev",
            },
        });
    }
    handleStart();
});
$(function () {
    $("#example-one").organicTabs();
    $(".news #example-one .nav li").each(function () {
        if ($(this).find("a").hasClass("current")) {
            var currentObj = $(this).find("a").attr("href");
            $("" + currentObj).show();
            $("" + currentObj)
                .siblings(":not(.nav)")
                .hide();
        }
    });
    $(".animated2").addClass("uhide");
});
function gx() {
    $(".gx").addClass("border");
    $(".qt").removeClass("border");
    $(".animated2").removeClass("uhide");
    $(".animated2").show();
    $(".animated3").hide();
}
function qt() {
    $(".qt").addClass("border");
    $(".gx").removeClass("border");
    $(".animated3").removeClass("uhide");
    $(".animated2").hide();
    $(".animated3").show();
}
function handleStart() {
    $("#view img.lazy")
        .not("[data-isLoaded]")
        .each(function () {
            var $node = $(this);
            if (isShow($node)) {
                loadImg($node);
            }
        });
}
function isShow($node) {
    return $node.offset().top <= window.innerHeight + $(window).scrollTop();
}
function loadImg($img) {
    $img.attr("src", $img.attr("data-src"));
    $img.attr("data-isLoaded", 1);
}
